import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'
import { viteMockServe } from 'vite-plugin-mock'

// https://vite.dev/config/
export default defineConfig(() => ({
  plugins: [
    vue(),
    viteMockServe({
      mockPath: './src/mock',      // Mock 文件存放路径
      watchFiles: true,        // 监听 Mock 文件改动热更新
      reload: true // 修改后自动更新
    })
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `
          @use "@/style/viriables.scss" as *;
          @use "@/style/mixin.scss" as *;
        `
      }
    }
  },
  server: {
    port: 8080,
    hmr: true,
    host: '0.0.0.0'
  }
}))
